<?php
session_start();

define('DB_HOST',   'yallara.cs.rmit.edu.au:53936');
define('DB_NAME',   'happyendings');

define('DB_USER',   '');
define('DB_PW',     '');

if (!$dbconn = mysql_connect(DB_HOST, DB_USER, DB_PW)) {
  echo 'Could not connect to mysql on ' . DB_HOST . "\n";
  exit;
}

echo 'Connected to mysql on ' . DB_HOST . "<br/>\n";				//connect to mysql database

if (!mysql_select_db(DB_NAME, $dbconn)) {
  echo 'Could not use database ' . DB_NAME . "\n";
  echo mysql_error() . "\n";
  exit;
}

echo '<?xml version="1.0" encoding="UTF-8"?>';
echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">';
echo '<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">';
echo '<head>';
	echo '<title>Register</title>';
	echo '<link href="template.css" type="text/css" rel="stylesheet" />';
	echo '<link href="regcss.css" type="text/css" rel="stylesheet" />';
	

echo '</head>';

echo '<body>';
echo '<div id ="wrapper">';


echo '<div id = "logo"></div>';

echo '<div id="navBar">';

echo '<div class = "home"><a href ="index.php"><div id="homeLink"><div id ="homeLinkText">Home</div></div></a></div>';
echo '<div class = "search"><a href = "search_form.php"><div id ="searchLink"><div id ="searchLinkText">Search</div></div></a></div>';
echo '<div class ="contactUs"><a href = "contactUs.html"><div id ="contactUsLink"><div id ="contectUsText">Contact Us</div></div></a></div>';
echo '<div class = "register"><a href = "register_form.php"><div id ="registerLink"><div id ="registerText">Register</div></div></a> </div>';


echo '</div>';
echo '<div id = "regText"><h1>Register</h1></div>';
echo '<div id= register>';

echo '<form method = "POST" action = "register.php">';
echo '<table>';
echo '<tr>';
 echo '<td>Enter desired Nickname:</td>';
 echo '<td><input type = "text" name = "nickname" /></td>';
echo '</tr>';
echo '<tr>';
//echo '<tr>';
 echo '<td>Enter Password</td>';
 echo '<td><input type = "password" name = "password" /></td>';
echo '</tr>';
echo '<tr>';
 echo '<td>Enter Birthyear:</td>';
 echo '<td><input type = "text" name = "birthyear" /></td>';
echo '</tr><!--second Row-->';
echo '<tr>';
 echo '<td>Enter E-mail:<br /> E-Mail will be User Name</td>';
 echo '<td><input type = "text" name = "email" /></td> ';
echo '</tr><!--third Row-->';
 echo '<td>Select Sex</td>';
 echo '<td><input type="radio" name="sex" value="m" /> Male<br />';
 echo '<input type="radio" name="sex" value="f" /> Female</td>';
echo '</tr><!-- Fifth Row-->';

echo '<tr>';
echo '<td>';
echo 'Select Country';
echo '</td>';
echo '<td>';
echo '<select name=CountryName>';

	$query = "SELECT country_name FROM countries";
	mysql_select_db("happyendings", $dbconn);
	$result = mysql_query($query, $dbconn);
	$row = mysql_fetch_array($result);
	//echo "<option>Select Country</option>";
	$i=2;
	while($row = mysql_fetch_array($result))
	{
	   echo "<option value =".$i.">".$row['country_name']."</option>";
	   $i++;
	}

echo '</select>';
echo '</td>';

echo '</tr>';
echo '<tr>';
echo '<td>';
echo 'Click to submit Registration';
echo '</td>';
echo '<td><input type = "submit" value = "Register" /></td>';
echo '</tr>';
echo '</table>';

echo '</form>';

echo '</div>';

echo '<div id="textHide">';
echo '<!--using the periods to expand the wrapper box-->';
echo '.<br />';
echo '.<br />';
echo '.';
echo '</div>';

echo '</div>';


echo '</body>';
echo '</html>';
?>